home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 009 / smartrm1.arc / STFIX.ASM < prev    next >
Encoding:
Assembly Source File  |  1985-12-27  |  5.0 KB  |  181 lines

  1.     page    60,132
  2. TITLE    STFIX -  Resident routine to give ST100.EXE what it wants. 
  3. ;-------------------------------------------------------------------
  4. ;
  5. ;    Install this routine to catch calls to INT 13H for drive
  6. ;    A:, track 40.  This routine makes ST100.EXE think that
  7. ;    it got what it wanted.  Use for SMARTERM 100 ver. 4.0c
  8. ;
  9. ;    by Keith M. Bailey           12/29/85      version 0.01
  10. ;
  11. ;-------------------------------------------------------------------
  12. CODESG    SEGMENT
  13.     ASSUME CS:CODESG,DS:NOTHING,ES:NOTHING
  14.     ORG    0100H
  15. STFIX    PROC    FAR
  16.     JMP    START
  17.  
  18.     ORG    0110H
  19. FILE1    LABEL    BYTE
  20. SECTORS    DB    0400H*9 DUP('?')    ;Space to store decoded sectors
  21.  
  22. OFF_13H        DW    00    ;Store offset for original INT 13H 
  23. SEG_13H        DW    00    ;Store segment for original INT 13H
  24. ON        DB    00    ;Flag to indicate if trapping is used
  25.  
  26.  
  27. ;New routine for INT 13H
  28.  
  29. NEW_13H:
  30.     STI            ;Enable interrupts
  31.     PUSHF            ;Save flags
  32.     CMP    AH,00        ;Is it a reset ?
  33.     JE    RESET        ;   Yes
  34.     CMP    CH,27H        ;Call for track 39 ?
  35.     JE    TRCK39        ;   Yes
  36.     CMP    CH,28H        ;Call for track 40 ?
  37.     JNE    NOTRAP        ;   No
  38.     CMP    DL,00        ;Call for drive A: ?
  39.     JNE    NOTRAP        ;   No
  40.     CMP    ON,0FFH        ;Is flag set  (ON = FFH) ?
  41.     JE    TRAP        ;   Yes
  42.  
  43. NOTRAP:    POPF            ;No trapping ... just go to old INT 13H
  44.     PUSHF            ;Give something for INT 13H to pop on return
  45.     CALL    DWORD PTR CS:OFF_13H    ;Original INT 13H
  46.     RET    2        ;Return and throw away flags
  47.  
  48. TRCK39: CMP    ON,00        ;Is flag off
  49.     JE    NOTRAP        ;   Yes
  50.     CMP    AH,04        ;Is it a verify ?
  51.     JNE    NOTRAP        ;   No
  52.     CMP    DL,00        ;Call for drive A: ?
  53.     JNE    NOTRAP        ;   No
  54.     POPF
  55.     MOV    AX,0F206H    ;Set flags for no error.
  56.     PUSH    AX
  57.     POPF
  58.     MOV    AX,00        ;Set AH for no error.
  59.     RET    2        ;Return and throw away flags
  60.  
  61. RESET:    CMP    ON,00        ;Is flag off
  62.     JE    NOTRAP        ;   Yes
  63.     POPF            ;Restore flags
  64.     PUSH    DX        ;CX and DX aren't changed
  65.     PUSH    CX
  66.     MOV    DX,0000        ;Set up AX, CX, and DX for a reset
  67.     MOV    CX,005CH    ;   that I know works !
  68.     MOV    AX,00FDH
  69.     PUSHF            ;Give something for INT 13H to pop on return
  70.     CALL    DWORD PTR CS:OFF_13H    ;Original INT 13H
  71.     POP    CX        ;Restore CX and DX ... others are okay
  72.     POP    DX
  73.     RET    2        ;Return and throw away flags
  74.  
  75. TRAP:    POPF            ;Trap for calls from ST100.EXE
  76.     PUSH    DS        ;Save segments and registers
  77.     PUSH    DI
  78.     PUSH    SI
  79.     PUSH    DX
  80.     PUSH    CX
  81.     PUSH    BX
  82.     CMP    AH,04        ;Is it a verify operation ?
  83.     MOV    AX,00
  84.     MOV    DS,AX        ;Set DS = 0000
  85.     LDS    SI,DS:[1EH*4]    ;DS:SI points to disk parameter table
  86.     JE    VERIFY        ;   Yes - a verify operation
  87.                 ;   No  - a read operation
  88.     DEC    CL        ;Decrease sector to read by one
  89.     MOV    CH,00        ;CX = # sectors offset from 1
  90.     MOV    AX,0400H    ;Number of bytes per sector
  91.     MUL    CX        ;DX:AX has product ... AX is offset from FILE1
  92.     MOV    CX,0200H    ;Number of bytes to be read
  93.     CMP    BYTE PTR DS:[SI+3],02    ;Is # bytes = 0200H ?
  94.     JE    SMALL        ;   Yes
  95.     MOV    CX,0400H    ;   No --- # bytes to read = 0400H
  96.  
  97. SMALL:    MOV    DI,BX        ;ES:DI points to buffer to move segment into
  98.     MOV    DX,CS
  99.     MOV    DS,DX        ;Set DS = CS
  100.     MOV    SI,OFFSET FILE1    ;Start of segments
  101.     ADD    SI,AX        ;Add offset calculated above
  102.     CLD
  103.     REPNZ    MOVSB        ;Move the correct # of bytes into buffer
  104.  
  105.     MOV    AX,00
  106.     MOV    DS,AX        ;Set DS = 0000
  107.     LDS    SI,DS:[1EH*4]    ;DS:SI points to disk parameters
  108.  
  109. VERIFY:    CMP    BYTE PTR DS:[SI+3],03    ;1024 byte sectors ?
  110.     JE    VERERR        ;   Yes - operation sets error condition
  111. TR9V:    MOV    AX,0F246H    ;Set flags for return - no error
  112.     PUSH    AX
  113.     POPF
  114.     MOV    AX,00        ;Set AX for return - no error
  115.     JMP    BYE        ;Leave
  116.  
  117. VERERR:    CMP    CL,09        ;Is it for sector 9 ?
  118.     JE    TR9V        ;   Yes - no error from operation !
  119.     MOV    AX,0F247H    ;Set flags for return - error
  120.     PUSH    AX
  121.     POPF
  122.     MOV    AX,1000H    ;Set AX for return - CRC error
  123.  
  124. BYE:    POP    BX        ;Restore flags and segments
  125.     POP    CX
  126.     POP    DX
  127.     POP    SI
  128.     POP    DI
  129.     POP    DS
  130.     RET    2        ;Return ... throw away flags
  131.  
  132.  
  133. ;Routine to load resident portion
  134.  
  135. START:    MOV    AX,00
  136.     MOV    DS,AX            ;Set DS to 0000
  137.     MOV    DX,OFFSET ALLRDY    ;Point to error message
  138.     LDS    SI,DS:[13H*4]        ;Point to INT 13H
  139.     CMP    WORD PTR DS:[SI],9CFBH    ;Is STFIX installed ?
  140.     JE    NOTRES            ;   Yes - don't install
  141.  
  142. RESID:    CLI                ;Disable interrupts while
  143.                     ;   changing interrupt vectors
  144.     MOV    CS:OFF_13H,SI        ;Move offset for INT 13H
  145.                     ;   into memory location
  146.     MOV    CS:SEG_13H,DS        ;Move segment for INT 13H
  147.     MOV    AX,00            ;   into memory location
  148.     MOV    DS,AX            ;Set DS to 0000
  149.     MOV    WORD PTR DS:[13H*4],OFFSET NEW_13H    ;Set INT 13H offset
  150.     MOV    DS:[13H*4+2],CS        ;Set INT 13H segment
  151.     STI                ;Enable interrupts
  152.  
  153.     MOV    DX,OFFSET INSTLL    ;Point to installed message
  154.     MOV    AX,CS            ;DS:DX points to string
  155.     MOV    DS,AX
  156.     MOV    AH,09H
  157.     INT    21H            ;Print string
  158.  
  159.     MOV    DX,OFFSET START        ;Move into DX size of memory
  160.                     ;   to protect
  161.     INT    27H            ;Terminate, but remain resident
  162.  
  163.  
  164. NOTRES:    CMP    WORD PTR DS:[SI+2],0FC80H    ;Make sure it's mine
  165.     JNE    RESID            ;   No - install
  166.     MOV    AX,CS            ;DS:DX points to string
  167.     MOV    DS,AX
  168.     MOV    AH,09H
  169.     INT    21H            ;Print string
  170.     INT    20H            ;Terminate
  171.  
  172. STFIX    ENDP
  173.  
  174. ALLRDY    DB    0DH,0AH,'STFIX has already been installed.  Use STFIXON to '
  175.     DB    'toggle ON and OFF.',0DH,0AH,'$'
  176. INSTLL    DB    0DH,0AH,'STFIX is now installed.  Use STFIXON to '
  177.     DB    'toggle ON and OFF.',0DH,0AH,'$'
  178.  
  179. CODESG    ENDS
  180.     END    STFIX
  181.